package com.baiyinet.di;

import android.app.Application;

import com.baiyinet.DaggerMyAppComponent;
import com.baiyinet.MyAppComponent;
import com.baiyinet.di.module.AppModule;
import com.baiyinet.receiver.DaggerPushReceiverComponent;
import com.baiyinet.receiver.PushReceiverComponent;
import com.baiyinet.ui.general.DaggerGeneralActivityComponent;
import com.baiyinet.ui.general.GeneralActivityComponent;
import com.baiyinet.ui.login.DaggerLoginActivityComponent;
import com.baiyinet.ui.login.DaggerLoginAdActivityComponent;
import com.baiyinet.ui.login.LoginActivityComponent;
import com.baiyinet.ui.login.LoginAdActivityComponent;
import com.baiyinet.ui.main.DaggerMainActivityComponent;
import com.baiyinet.ui.main.MainActivityComponent;
import com.baiyinet.ui.player.AliyunPlayerActivityComponent;
import com.baiyinet.ui.player.DaggerAliyunPlayerActivityComponent;
import com.baiyinet.ui.share.DaggerShareModeDialogActivityComponent;
import com.baiyinet.ui.share.ShareModeDialogActivityComponent;
import com.baiyinet.ui.splash.DaggerSplashActivityComponent;
import com.baiyinet.ui.splash.SplashActivityComponent;


/**
 * @author J.Huang
 * @version 1.0
 * @since 16/10/18
 */
public class Injector {

    private static MyAppComponent mAppComponent = null;

    private Injector() {}

    public static MyAppComponent initMyAppComponent(Application app) {
        mAppComponent = null;
        mAppComponent = DaggerMyAppComponent.builder()
                .appModule(new AppModule(app))
                .build();
        return mAppComponent;
    }

    public static SplashActivityComponent initSplashActivityComponent() {
        SplashActivityComponent splashActivityComponent = null;
        if (mAppComponent != null) {
            splashActivityComponent = DaggerSplashActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return splashActivityComponent;
    }

    public static LoginActivityComponent initLoginActivityComponent() {
        LoginActivityComponent loginActivityComponent = null;
        if (mAppComponent != null) {
            loginActivityComponent = DaggerLoginActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return loginActivityComponent;
    }

    public static LoginAdActivityComponent initLoginAdActivityComponent() {
        LoginAdActivityComponent loginAdActivityComponent = null;
        if (mAppComponent != null) {
            loginAdActivityComponent = DaggerLoginAdActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return loginAdActivityComponent;
    }

    public static GeneralActivityComponent initGeneralActivityComponent() {
        GeneralActivityComponent generalActivityComponent = null;
        if (mAppComponent != null) {
            generalActivityComponent = DaggerGeneralActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return generalActivityComponent;
    }

    public static MainActivityComponent initMainActivityComponent() {
        MainActivityComponent mainActivityComponent = null;
        if (mAppComponent != null) {
            mainActivityComponent = DaggerMainActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return mainActivityComponent;
    }

    public static PushReceiverComponent initPushReceiverComponent() {
        PushReceiverComponent component = null;
        if (mAppComponent != null) {
            component = DaggerPushReceiverComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static ShareModeDialogActivityComponent initShareModeDialogActivityComponent() {
        ShareModeDialogActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerShareModeDialogActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static AliyunPlayerActivityComponent initAliyunPlayerActivityComponent() {
        AliyunPlayerActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerAliyunPlayerActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }
}
